package com.ak.game.factory;

import cn.hutool.core.util.StrUtil;
import com.ak.game.handler.GameAbstractHandler;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 游戏工厂类
 */
@Component
public class GameFactory {
    private static Map<String, GameAbstractHandler> strategyMap = new HashMap<>();

    public static GameAbstractHandler getInvokeStrategy(String name){
        return strategyMap.get(name);
    }

    public static void register(String str, GameAbstractHandler handler) {
        if (StrUtil.isEmpty(str) || null == handler) {
            return;
        }
        strategyMap.put(str,handler);
    }
}
